package com.lmaos.basetools.menuList;

import com.lmaos.basetools.sText.TextUtils;

public class MenuItem {
	/** 是一个菜单-集合 */
	public final static int MENU_LIST=1;
	/** 是一个实体项 */
	public final static int MENU_ITEM=0;
	/** 被删除的 */
	public final static int STATE_DELETE = 2;
	/** 隐藏的 */
	public final static int STATE_HIDE = 3;
	
	private long menuid;		// id 每个菜单有一个唯一的菜单id
	private String asname;	// 别名
	private String jumpUrl; // 跳转的资源连接
	private int menuType; 	// 菜单类型
	private String absoluteMenuPath; // 绝对路径
	
	private String createFrom; // 创建来源
	private String createDate; // 创建日期
	private String createTime; // 创建时间
	
	private String smallIcon;	// 小图标	
	private String mediumIcon;	// 中图标
	private String largeIcon;	// 大图标
	
	private int state;			// 菜单状态
	private boolean temp;		// 是一个临时被创建的
//	private Object exData;	// 扩展数据
	public MenuItem(String absoluteMenuPath) {
		setAbsoluteMenuPath(absoluteMenuPath);
	}
	public MenuItem(int menuType,String absoluteMenuPath) {
		this.menuType = menuType;
		setAbsoluteMenuPath(absoluteMenuPath);
	}
	public long getMenuid() {
		return menuid;
	}
	public void setMenuid(long menuid) {
		this.menuid = menuid;
	}
	public String getAsname() {
		return asname;
	}
	public void setAsname(String asname) {
		this.asname = asname;
	}
	public String getJumpUrl() {
		return jumpUrl;
	}
	public void setJumpUrl(String jumpUrl) {
		this.jumpUrl = jumpUrl;
	}
	public int getMenuType() {
		return menuType;
	}
	public void setMenuType(int menuType) {
		this.menuType = menuType;
	}
	public String getAbsoluteMenuPath() {
		if(isMenuList()){
			return  TextUtils.formatTextEnd(absoluteMenuPath, "/");
		}
		return absoluteMenuPath;
	}
	public void setAbsoluteMenuPath(String absoluteMenuPath) {
		this.absoluteMenuPath = absoluteMenuPath.replace("\\", "/");
		if(absoluteMenuPath.endsWith("/")){
			menuType = 1;
		}
	}
	public String getCreateFrom() {
		return createFrom;
	}
	public void setCreateFrom(String createFrom) {
		this.createFrom = createFrom;
	}
	public String getCreateDate() {
		return createDate;
	}
	public void setCreateDate(String createDate) {
		this.createDate = createDate;
	}
	public String getCreateTime() {
		return createTime;
	}
	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}

	public boolean isMenuList(){
		return getMenuType() == MENU_LIST;
	}
	public boolean isMenuItem(){
		return getMenuType() == MENU_ITEM;
	}
	
//	public void setExData(Object exData) {
//		this.exData = exData;
//	}
	
	
	public String getSmallIcon() {
		return smallIcon;
	}
	public void setSmallIcon(String smallIcon) {
		this.smallIcon = smallIcon;
	}
	public String getMediumIcon() {
		return mediumIcon;
	}
	public void setMediumIcon(String mediumIcon) {
		this.mediumIcon = mediumIcon;
	}
	public String getLargeIcon() {
		return largeIcon;
	}
	public void setLargeIcon(String largeIcon) {
		this.largeIcon = largeIcon;
	}
	public int getState() {
		return state;
	}
	public void setState(int state) {
		this.state = state;
	}
//	public Object getExData() {
//		return exData;
//	}
	public boolean isTemp() {
		return temp;
	}
	public MenuItem setTemp(boolean temp) {
		this.temp = temp;
		return this;
	}
	@Override
	public String toString() {
		if (asname!=null) {
			return asname;
		}else{
			return absoluteMenuPath;
		}
	}
}
